﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace Brain.Editor.Controls
{
    public partial class InterfaceHolder : UserControl
    {
        private object Object;

        public InterfaceHolder()
        {
            InitializeComponent();
        }
        public InterfaceHolder(Panel panel, object ob)
        {
            InitializeComponent();

            panel.Controls.Add(this);

            this.Object = ob;

            Charge();
        }
        protected InterfaceHolder(Panel panel, int Y, object ob)
        {
            this.Object = ob;

            Charge();
        }

        private void Charge()
        {
            if (Object is ITextured)
            {
                this.label1.Text = "Texture";
            }
            else if (Object is IModeled)
            {
                this.label1.Text = "Model";
            }
        }

        private void panel_Drop_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            ContentManagerForm manager = new ContentManagerForm(true);
            if (manager.ShowDialog() == DialogResult.OK)
            {
                SceneContentFile file = manager.SelectedFile;
                string final = "confile:" + file.Name;

                if (Object is ITextured)
                {
                    (Object as ITextured).TexturePlace = final;
                }
                if (Object is IModeled)
                {
                    (Object as IModeled).ModelPlace = final;
                }
            }
        }
    }
}
